package fr.sharpe.app.earthvisualizationdatamodel;

import java.awt.Dimension;
import java.io.Serializable;

import gov.nasa.worldwind.avlist.AVListImpl;
import gov.nasa.worldwind.geom.LatLon;
import gov.nasa.worldwind.geom.Position;
import gov.nasa.worldwind.render.AbstractSurfaceObject;
import gov.nasa.worldwind.render.SurfaceIcon;
import gov.nasa.worldwind.render.UserFacingIcon;
import gov.nasa.worldwind.render.WWIcon;

public class Icon extends Surface implements Serializable{

	private String id;
	private double latitude;
	private double longitude;
	private String pathToFile;
	private int width;
	private int height;
	private UserFacingIcon icon = null;
	private Data data;
	
	public Icon(String id,double latitude, double longitude, String pathToFile,int width, int height, Data data)
	{
		this.id = id;
		this.latitude = latitude;
		this.longitude = longitude;
		this.height = height;
		this.width = width;
		this.pathToFile = pathToFile;
		this.setData(data);
	}

	@Override
	public AVListImpl getShape() {

		if(icon == null)
		{
			UserFacingIcon icon = new UserFacingIcon();
			icon.setImageSource(pathToFile);
			icon.setPosition(new Position(LatLon.fromDegrees(latitude, longitude), 0));
			icon.setSize(new Dimension(width, height));	
//			icon.setShowToolTip(true);
//			icon.setToolTipText(this.getToolTipFromData());
			return icon;
		}
		else
		{
			
			icon.setPosition(new Position(LatLon.fromDegrees(latitude, longitude), 0));
			icon.setSize(new Dimension(width, height));
//			icon.setShowToolTip(true);
//			icon.setToolTipText(this.getToolTipFromData());
			return icon;
		}
	}

	public double getLatitude() {
		return latitude;
	}

	public void setLatitude(double latitude) {
		this.latitude = latitude;
	}

	public double getLongitude() {
		return longitude;
	}

	public void setLongitude(double longitude) {
		this.longitude = longitude;
	}

	public String getPathToFile() {
		return pathToFile;
	}

	public void setPathToFile(String pathToFile) {
		this.pathToFile = pathToFile;
	}

	@Override
	public String getId() {
		return this.id;
	}

	public void setData(Data data) {
		this.data = data;
	}

	public Data getData() {
		return data;
	}

}
